home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / ebksrc.zip / PCFRAME.HPP < prev    next >
C/C++ Source or Header  |  1991-07-30  |  2KB  |  77 lines

  1. /*
  2.  
  3.     pcframe.hpp
  4.     7-30-91
  5.     Text mode framing for the IBM PC.
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All right reserved
  10.     Use freely but acknowledge authorship and copyright.
  11.  
  12.  
  13.     PSW / Power SoftWare
  14.     P.O. Box 10072
  15.     McLean, Virginia 22102 8072 USA
  16.  
  17.     John Small
  18.     Voice: (703) 759-3838
  19.     CIS: 73757,2233
  20.  
  21. */
  22.  
  23. #ifndef PCFRAME_HPP
  24. #define PCFRAME_HPP
  25.  
  26. #include <conio.h>
  27.  
  28. class TextFraming  {
  29.     static unsigned char frame[];
  30.     static int buf[];
  31.     static struct text_info ti;
  32.     int puttext(int l, int t, int r, int b, void *buf);
  33.     // keep ::puttext() from crashing on bad dimensions.
  34. public:
  35.     enum LSTYLE { SINGLE, DOUBLE, LSTYLES };
  36.     enum LDIR { VERTICAL, HORIZONAL, LDIRS };
  37.     enum BSTYLE { SVSH, DVDH, SVDH,
  38.         DVSH, BSTYLES };
  39.     enum BCHAR { VERT, HORIZ, UPPER_LEFT,
  40.         MIDDLE_TOP, UPPER_RIGHT,
  41.         MIDDLE_RIGHT, LOWER_RIGHT,
  42.         MIDDLE_BOTTOM, LOWER_LEFT,
  43.         MIDDLE_LEFT, CROSS, BCHARS };
  44.     void reset()  { gettextinfo(&ti); }
  45.     // Call reset after every textmode change!
  46.     TextFraming() { reset(); }
  47.     int validDimensions(int left, int top, int right,
  48.         int bottom);
  49.     int validateDimensions(int& left, int& top,
  50.         int& right, int& bottom,
  51.         unsigned minWidth, unsigned minHeight);
  52.     unsigned char lnChar(enum LSTYLE ls,
  53.         enum LDIR ld)    { return
  54.         frame[ls*BCHARS+ld]; }
  55.     unsigned char bxChar(enum BSTYLE bs,
  56.         enum BCHAR bc) { return
  57.         frame[bs*BCHARS+bc]; }
  58.     void vline(int x, int top, int bottom, int attr,
  59.         enum LSTYLE ls);
  60.     void hline(int y, int left, int right, int attr,
  61.         enum LSTYLE ls);
  62.     void box(int left, int top, int right, int bottom,
  63.         int attr, enum BSTYLE bs);
  64. };
  65.  
  66. extern TextFraming PCF;
  67.  
  68. typedef TextFraming TxtFrmg;
  69.  
  70. #define NO_FRAME    TxtFrmg::BSTYLES
  71. #define SINGLE_FRAME    TxtFrmg::SVSH
  72. #define DOUBLE_FRAME    TxtFrmg::DVDH
  73. #define MAX_TF_BUF    132
  74.  
  75.  
  76. #endif
  77.